﻿using Curry.Forum.Api.Attributes;
using Curry.Forum.Api.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Cors;
using Newtonsoft.Json;
using Curry.Forum.Command.Handler.AutoFac;
using Curry.Forum.Command.Handler.CommandHandler;
using Curry.Forum.Facade;

namespace Curry.Forum.Api.Controllers
{
    [RoutePrefix("api/User")]
    public class UserController : ApiController
    {
        [HttpPost]
        [Route("GetUserInfo")]
        [ApiAuthorize]
        public BasicResponse GetUserInfo()
        {
            AuthInfo info = RequestContext.RouteData.Values["auth"] as AuthInfo;

            if (info == null)
            {
                BasicResponse response = new BasicResponse();
                response.ErrorMsg = "未获取到用户信息";
                response.RtnCode = 101;
                return response;
            }
            else
            {
                return AutofacExt.GetFromFac<UserHandler>().GetUserInfo(info.UserName);
            }
        }
    }
}
